home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Burning & Media
/
GB-PVR 1.2.13
/
GBPVR10213.msi
/
Cabs.w1.cab
/
SearchResults2.aspx.cs584
< prev
next >
Wrap
Text File
|
2008-04-02
|
45KB
|
887 lines
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data.Common;
using System.IO;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web;
using System.Xml;
using GBPVR.Public;
using GBPVRSchedule;
using gbweb.classes;
namespace gbweb
{
/// <summary>
/// Summary description for SearchResults.
/// </summary>
public partial class SearchResults2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected Settings guideParams;
protected ProgramTreeItem[] pgmTree;
protected int treeIdx;
private string sortOrder = string.Empty;
private ArrayList sortOrders;
private ArrayList displayProgrammeSort = new ArrayList();
Hashtable channelCache = new Hashtable();
protected void Page_Load(object sender, System.EventArgs e)
{
treeIdx = 0;
pgmTree = new ProgramTreeItem[10000];
guideParams = Global.Settings;
HttpCookie cookie = Request.Cookies["showSearchResults"];
//Clear out the listings area so that you don't get leftovers from the previous display
CONTENTS.InnerHtml = "";
//Remove a programme if someone clicked on Cancel prior t loading the list of programmes so that it is gone and does not appear again
string cancel = null;
cancel = Request.Params["cancel"];
if ((cancel != null) && (cancel.Length > 0))
{
Schedule scheduleHelper = Global.Schedule;
ScheduledRecording scheduledRecording = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(cancel));
if (scheduledRecording != null)
{
scheduleHelper.CancelScheduledRecording(scheduledRecording);
}
}
//Only execute on the first page load
if (!IsPostBack)
{
//Set the Day/date/time display on the header
viewDate.InnerText = DateTime.Now.ToLongDateString().Trim();
serverTime.InnerText = "Server Time: " + DateTime.Now.ToLongTimeString().Trim();
//Set the header tab of the Search to active
NAV_SEARCH.Attributes.Add("class", "currentTab");
NAV_RECORDINGS.Visible = guideParams.showManage;
NAV_SEARCH.Visible = guideParams.showSearch;
NAV_VIDEO.Visible = guideParams.showVideoLib;
NAV_MUSIC.Visible = guideParams.showMusicLib;
NAV_PHOTO.Visible = guideParams.showPhotoLib;
NAV_STATS.Visible = guideParams.showStats;
//If the user has opted to use the TreeView search results allow the user to see the sort order
//options otherwise do not show them
XmlNode pre = Global.Config.SelectSingleNode("/settings/PreShowPadding");
XmlNode post = Global.Config.SelectSingleNode("/settings/PostShowPadding");
prePadding.Text = pre.InnerText;
postPadding.Text = post.InnerText;
sr_searchResults.SelectedValue = cookie != null ? cookie.Value : "table";
if (sr_searchResults.SelectedValue == "tree")
{
treeControl.Visible = true;
sortResults.Visible = true;
sortResults2.Visible = true;
//If the user has ExtendedEWA then dynamicaly add a button for Star Rating sort
if (ExtendedEWA.Initialize())
{
ListItem starRating = new ListItem();
starRating.Text = "Star Rating";
starRating.Value = "star";
srtOrder.Items.Add(starRating);
ListItem originalAirDate = new ListItem();
originalAirDate.Text = "Original Air Date (oad)";
originalAirDate.Value = "originalAirDate";
srtOrder.Items.Add(originalAirDate);
}
//Set the selected search order to whatever was used on the search criteria page
string treeSortOrder = Convert.ToString(Session["SearchResultsOption"]);
if (treeSortOrder != null)
{
srtOrder.SelectedValue = sortOrder;
}
else
{
cookie = Request.Cookies["SearchSortOrder"];
srtOrder.SelectedValue = cookie != null ? cookie.Value : "title";
}
//Store the selected display (table or tree) in the cookie for the next search
cookie = new HttpCookie("showSearchResults", sr_searchResults.SelectedValue);
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
}
else
{
treeControl.Visible = false;
sortResults.Visible = false;
sortResults2.Visible = false;
}
if ((Request.Params["checkTitle"] != null) || (Request.Params["checkDescription"] != null) || (Request.Params["checkSubtitle"] != null) || (Request.Params["listChannels"] != null) ||
(Request.Params["matchTitle"] != null) || (Request.Params["matchDesc"] != null) || (Request.Params["matchSubtitle"] != null) || (Request.Params["matchUniqueID"] != null) ||
(Request.Params["textMinLength"] != null) && (Request.Params["textMinLength"].Length > 0) ||
((Request.Params["textMaxLength"] != null) && (Request.Params["textMaxLength"].Length > 0)) ||
Request.Params["startDate"] != null || Request.Params["startTime"] != null ||
Request.Params["endDate"] != null || Request.Params["endTime"] != null)
{
int minLength = int.MinValue;
int maxLength = int.MaxValue;
Session["startDate"] = "01/01/1901";
Session["startTime"] = "01:01 AM";
Session["endDate"] = "01/01/1901";
Session["endTime"] = "01:01 AM";
if ((Request.Params["textMinLength"] != null) && (Request.Params["textMinLength"].Length > 0)) minLength = int.Parse(Request.Params["textMinLength"]);
if ((Request.Params["textMaxLength"] != null) && (Request.Params["textMaxLength"].Length > 0)) maxLength = int.Parse(Request.Params["textMaxLength"]);
if ((Request.Params["startDate:textBox"] != null) && (Request.Params["startDate:textBox"].Length > 0))
{
Session["startDate"] = Request.Params["startDate:textBox"];
}
if ((Request.Params["startTime:textBox"] != null) && (Request.Params["startTime:textBox"].Length > 0))
{
Session["startTime"] = Request.Params["startTime:textBox"];
}
if ((Request.Params["endDate:textBox"] != null) && (Request.Params["endDate:textBox"].Length > 0))
{
Session["endDate"] = Request.Params["endDate:textBox"];
}
if ((Request.Params["endTime:textBox"] != null) && (Request.Params["endTime:textBox"].Length > 0))
{
Session["endTime"] = Request.Params["endTime:textBox"];
}
string[] channels = new string[0] { };
if (Request.Params["listChannels"] != null) channels = Request.Params["listChannels"].Split(',');
string[] genres = new string[0] { };
if (Request.Params["genreList"] != null) genres = Request.Params["genreList"].Split(',');
Session["checkTitle"] = Request.Params["checkTitle"] != null;
Session["checkDescription"] = Request.Params["checkDescription"] != null;
Session["checkSubtitle"] = Request.Params["checkSubtitle"] != null;
Session["matchTitle"] = Request.Params["matchTitle"] != null;
Session["matchDesc"] = Request.Params["matchDesc"] != null;
Session["matchSubtitle"] = Request.Params["matchSubtitle"] != null;
Session["matchUniqueID"] = Request.Params["matchUniqueID"] != null;
Session["textKeyWord"] = Request.Params["searchPhrase"];
Session["caseSensitive"] = Request.Params["caseSensitive"] != null;
Session["genreList"] = genres;
Session["minLength"] = minLength;
Session["maxLength"] = maxLength;
Session["channels"] = channels;
//Set the default recording Quality
quality.SelectedValue = Global.Settings.recordingQuality;
}
else
{
if (Request["sort"] == null)
{
Response.Redirect("Search2.aspx");
}
}
}
else
{
if (sr_searchResults.SelectedValue == "tree")
{
treeControl.Visible = true;
sortResults.Visible = true;
sortResults2.Visible = true;
}
else
{
treeControl.Visible = false;
sortResults.Visible = false;
sortResults2.Visible = false;
}
}
//Store the selected sort order in the cookie for the next search
cookie = new HttpCookie("SearchSortOrder", srtOrder.SelectedValue);
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
//Store the selected display (table or tree) in the cookie for the next search
//
cookie = new HttpCookie("showSearchResults", sr_searchResults.SelectedValue);
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
//Read the cookie for the sort order of the display
cookie = Request.Cookies["sortOrderSearch"];
sortOrder = cookie != null ? cookie.Value.Trim(',') : "datetime,channel,title,status";
sortOrders = new ArrayList(sortOrder.Split(','));
string newSort = Request["sort"];
if (newSort != null)
{
if (sortOrders.Contains(newSort))
{
if (sortOrders[0].ToString() == newSort)
{
sortOrders.Remove(newSort);
sortOrders.Insert(0, newSort + " desc");
}
else
{
sortOrders.Remove(newSort);
sortOrders.Insert(0, newSort);
}
}
else
{
sortOrders.Remove(newSort + " desc");
sortOrders.Insert(0, newSort);
}
}
sortOrder = string.Join(",", (string[])sortOrders.ToArray(typeof(string)));
//Update the sort settings in the cookie for the next display
cookie = new HttpCookie("sortOrderSearch", sortOrder);
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
processViews();
}
#region Page Load code for common processing of views - processViews
private void processViews()
{
//Turn on the appropriate display elements while turning off the one not being used
if (sr_searchResults.SelectedValue == "table")
{
RECORDINGS_HEADER.Visible = true;
SORT_HEADER.Visible = false;
}
else
{
forcedScrollbar.InnerHtml = "";
SORT_HEADER.Visible = true;
RECORDINGS_HEADER.Visible = false;
}
}
#endregion
protected void SearchResults_PreRender(object sender, System.EventArgs e)
{
SearchForEpisode(
(bool)Session["checkTitle"],
(bool)Session["checkDescription"],
(bool)Session["checkSubtitle"],
(bool)Session["matchTitle"],
(bool)Session["matchDesc"],
(bool)Session["matchSubtitle"],
(bool)Session["matchUniqueID"],
(string)Session["textKeyWord"],
(bool)Session["caseSensitive"],
(int)Session["minLength"],
(int)Session["maxLength"],
(string[])Session["channels"],
(string[])Session["genreList"],
(string)Session["startDate"],
(string)Session["startTime"],
(string)Session["endDate"],
(string)Session["endTime"]);
}
protected void hlRecord_Click(object sender, System.EventArgs e)
{
// schedule recordings
Schedule.Quality quality = 0;
switch (Request.Params["quality"].ToLower())
{
case "high":
quality = Schedule.Quality.High;
break;
case "medium":
quality = Schedule.Quality.Medium;
break;
case "low":
quality = Schedule.Quality.Low;
break;
case "custom1":
quality = Schedule.Quality.Custom1;
break;
case "custom2":
quality = Schedule.Quality.Custom2;
break;
}
Schedule scheduleHelper = Global.Schedule;
int prePad = Convert.ToInt32(prePadding.Text);
int postPad = Convert.ToInt32(postPadding.Text);
if (radioTime.SelectedValue == "once")
{
if (sr_searchResults.SelectedValue != "tree")
{
foreach (string param in Request.Params.Keys)
{
if (param.StartsWith("item"))
{
Programme programme = scheduleHelper.GetProgrammeByOID(int.Parse(param.Substring(4)));
Schedule myschedule = Global.Schedule;
if (Convert.ToDouble(extendMinutes.Text) != 0)
{
//Add the number of minutes that was entered to the end time of the recording to set the new end time
DateTime newEndDate =
programme.getEndTime().AddMinutes(Convert.ToDouble(extendMinutes.Text));
//Set the new end time for the recording
programme.setEndTime(newEndDate);
}
bool scheduleReturn = myschedule.ScheduleOnce(programme, quality, prePad, postPad);
Channel chnl = myschedule.GetChannelByOID(programme.getChannelOID());
Recordings.Items.Add(programme.getOID().ToString() + "@" + chnl.channelName + " " + programme.getTitle().ToString() + " " + programme.getStartTime().ToLongDateString() + " " + programme.getStartTime().ToShortTimeString() + " - " + programme.getEndTime().ToShortTimeString());
}
}
}
else
{
foreach (TreeNode node in TreeView1.CheckedNodes)
{
Programme programme = scheduleHelper.GetProgrammeByOID(System.Convert.ToInt32(node.Value));
Schedule myschedule = Global.Schedule;
if (Convert.ToDouble(extendMinutes.Text) != 0)
{
//Add the number of minutes that was entered to the end time of the recording to set the new end time
DateTime newEndDate =
programme.getEndTime().AddMinutes(Convert.ToDouble(extendMinutes.Text));
//Set the new end time for the recording
programme.setEndTime(newEndDate);
}
bool scheduleReturn = myschedule.ScheduleOnce(programme, quality, prePad, postPad);
Channel chnl = myschedule.GetChannelByOID(programme.getChannelOID());
Recordings.Items.Add(programme.getOID().ToString() + "@" + chnl.channelName + " " + programme.getTitle().ToString() + " " + programme.getStartTime().ToLongDateString() + " " + programme.getStartTime().ToShortTimeString() + " - " + programme.getEndTime().ToShortTimeString());
}
}
}
else
{
HybridDictionary processedRecordings = new HybridDictionary();
if (sr_searchResults.SelectedValue != "tree")
{
foreach (string param in Request.Params.Keys)
{
if (param.StartsWith("item"))
{
Programme programme = scheduleHelper.GetProgrammeByOID(int.Parse(param.Substring(4)));
if (Convert.ToDouble(extendMinutes.Text) != 0)
{
//Add the number of minutes that was entered to the end time of the recording to set the new end time
DateTime newEndDate =
programme.getEndTime().AddMinutes(Convert.ToDouble(extendMinutes.Text));
//Set the new end time for the recording
programme.setEndTime(newEndDate);
}
string uniqueProgrammeKey = programme.getChannelOID().ToString() + ":" + programme.getTitle();
if (!processedRecordings.Contains(uniqueProgrammeKey))
{
//Set the max number of recordings to keep for the show
int keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
if (keepRecordings.Text.ToString() != null)
{
try
{
keepnumRecordings = Convert.ToInt32(keepRecordings.Text);
}
catch
{
keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
}
}
else
{
keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
}
Schedule myschedule = Global.Schedule;
if (radioTime.SelectedValue == "thisTime")
{
// schedule season recording for any day and this time
if (radioDay.SelectedValue == "anyDay")
{
bool scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for only this day and this time
else if (radioDay.SelectedValue == "thisDay")
{
bool scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for the selected days and this time
else
{
ArrayList dayList = new ArrayList();
// Iterate through the Items collection of the checkedDays
// control and create the correct number for the season recording.
if (checkedDays_0.Checked)
{
dayList.Add(Schedule.Day.Monday);
}
if (checkedDays_1.Checked)
{
dayList.Add(Schedule.Day.Tuesday);
}
if (checkedDays_2.Checked)
{
dayList.Add(Schedule.Day.Wednesday);
}
if (checkedDays_3.Checked)
{
dayList.Add(Schedule.Day.Thursday);
}
if (checkedDays_4.Checked)
{
dayList.Add(Schedule.Day.Friday);
}
if (checkedDays_5.Checked)
{
dayList.Add(Schedule.Day.Saturday);
}
if (checkedDays_6.Checked)
{
dayList.Add(Schedule.Day.Sunday);
}
bool scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleSpecificDays, keepnumRecordings, dayList, Schedule.RecType.Season, prePad, postPad);
}
}
else
{
// schedule season recording for anyday anytime
if (radioDay.SelectedValue == "anyDay")
{
bool scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for only this day and thisany time
else if (radioDay.SelectedValue == "thisDay")
{
bool scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for the selected days and this time
else
{
ArrayList dayList = new ArrayList();
// Iterate through the Items collection of the checkedDays
// control and create the correct number for the season recording.
if (checkedDays_0.Checked)
{
dayList.Add(Schedule.Day.Monday);
}
if (checkedDays_1.Checked)
{
dayList.Add(Schedule.Day.Tuesday);
}
if (checkedDays_2.Checked)
{
dayList.Add(Schedule.Day.Wednesday);
}
if (checkedDays_3.Checked)
{
dayList.Add(Schedule.Day.Thursday);
}
if (checkedDays_4.Checked)
{
dayList.Add(Schedule.Day.Friday);
}
if (checkedDays_5.Checked)
{
dayList.Add(Schedule.Day.Saturday);
}
if (checkedDays_6.Checked)
{
dayList.Add(Schedule.Day.Sunday);
}
bool scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleSpecificDays, keepnumRecordings, dayList, Schedule.RecType.Season, prePad, postPad);
}
}
// drop out after first season recording for the show
// (it really doesn't matter what we store here, but myRecording sounds usefull)
processedRecordings.Add(uniqueProgrammeKey, programme);
Channel chnl = myschedule.GetChannelByOID(programme.getChannelOID());
Recordings.Items.Add(programme.getOID().ToString() + "@" + chnl.channelName + " " + programme.getTitle().ToString() + " " + programme.getStartTime().ToLongDateString() + " " + programme.getStartTime().ToShortTimeString() + " - " + programme.getEndTime().ToShortTimeString());
}
}
}
}
else
{
foreach (TreeNode node in TreeView1.CheckedNodes)
{
Programme programme = scheduleHelper.GetProgrammeByOID(System.Convert.ToInt32(node.Value));
if (Convert.ToDouble(extendMinutes.Text) != 0)
{
//Add the number of minutes that was entered to the end time of the recording to set the new end time
DateTime newEndDate =
programme.getEndTime().AddMinutes(Convert.ToDouble(extendMinutes.Text));
//Set the new end time for the recording
programme.setEndTime(newEndDate);
}
string uniqueProgrammeKey = programme.getChannelOID().ToString() + ":" + programme.getTitle();
if (!processedRecordings.Contains(uniqueProgrammeKey))
{
//Set the max number of recordings to keep for the show
int keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
if (keepRecordings.Text.ToString() != null)
{
try
{
keepnumRecordings = Convert.ToInt32(keepRecordings.Text);
}
catch
{
keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
}
}
else
{
keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
}
Schedule myschedule = Global.Schedule;
if (radioTime.SelectedValue == "thisTime")
{
// schedule season recording for any day and this time
if (radioDay.SelectedValue == "anyDay")
{
bool scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for only this day and this time
else if (radioDay.SelectedValue == "thisDay")
{
bool scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for the selected days and this time
else
{
ArrayList dayList = new ArrayList();
// Iterate through the Items collection of the checkedDays
// control and create the correct number for the season recording.
if (checkedDays_0.Checked)
{
dayList.Add(Schedule.Day.Monday);
}
if (checkedDays_1.Checked)
{
dayList.Add(Schedule.Day.Tuesday);
}
if (checkedDays_2.Checked)
{
dayList.Add(Schedule.Day.Wednesday);
}
if (checkedDays_3.Checked)
{
dayList.Add(Schedule.Day.Thursday);
}
if (checkedDays_4.Checked)
{
dayList.Add(Schedule.Day.Friday);
}
if (checkedDays_5.Checked)
{
dayList.Add(Schedule.Day.Saturday);
}
if (checkedDays_6.Checked)
{
dayList.Add(Schedule.Day.Sunday);
}
bool scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleSpecificDays, keepnumRecordings, dayList, Schedule.RecType.Season, prePad, postPad);
}
}
else
{
// schedule season recording for anyday anytime
if (radioDay.SelectedValue == "anyDay")
{
bool scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for only this day and thisany time
else if (radioDay.SelectedValue == "thisDay")
{
bool scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for the selected days and this time
else
{
ArrayList dayList = new ArrayList();
// Iterate through the Items collection of the checkedDays
// control and create the correct number for the season recording.
if (checkedDays_0.Checked)
{
dayList.Add(Schedule.Day.Monday);
}
if (checkedDays_1.Checked)
{
dayList.Add(Schedule.Day.Tuesday);
}
if (checkedDays_2.Checked)
{
dayList.Add(Schedule.Day.Wednesday);
}
if (checkedDays_3.Checked)
{
dayList.Add(Schedule.Day.Thursday);
}
if (checkedDays_4.Checked)
{
dayList.Add(Schedule.Day.Friday);
}
if (checkedDays_5.Checked)
{
dayList.Add(Schedule.Day.Saturday);
}
if (checkedDays_6.Checked)
{
dayList.Add(Schedule.Day.Sunday);
}
bool scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleSpecificDays, keepnumRecordings, dayList, Schedule.RecType.Season, prePad, postPad);
}
}
// drop out after first season recording for the show
// (it really doesn't matter what we store here, but myRecording sounds usefull)
processedRecordings.Add(uniqueProgrammeKey, programme);
Channel chnl = myschedule.GetChannelByOID(programme.getChannelOID());
Recordings.Items.Add(programme.getOID().ToString() + "@" + chnl.channelName + " " + programme.getTitle().ToString() + " " + programme.getStartTime().ToLongDateString() + " " + programme.getStartTime().ToShortTimeString() + " - " + programme.getEndTime().ToShortTimeString());
}
}
}
}
}
private void SearchForEpisode(
bool checkTitle, bool checkDesc, bool checkSubtitle,
bool matchTitle, bool matchDesc, bool matchSubtitle, bool matchUniqueID,
String searchFor, bool caseSensitive, int minLength, int maxLength,
string[] channels, string[] selectedGenre, string startdate, string starttime, string enddate, string endtime)
{
Schedule scheduleHelper = Global.Schedule;
ProgrammeDisplay2 displayProgramme = new ProgrammeDisplay2();
displayProgrammeSort = new ArrayList();
// build up a list of the recording we already know about
IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
Type pageType = Type.GetType("gbweb.SearchResults2");
if (sr_searchResults.SelectedValue != "tree")
{
createHeaderRow();
}
if (searchFor != null)
{
if (!caseSensitive)
{
searchFor = searchFor.ToUpper();
}
}
//Instantiate a new search engine
SearchEngine search = new SearchEngine();
//Set the date variables for search processing
search.setSearchDateTime(startdate, starttime, enddate, endtime);
//Call the method that will load an array with programmes that match the passed in search criteria
ArrayList ProgrammeArray = new ArrayList(search.SelectProgrammes(channels, selectedGenre, checkTitle, checkDesc, checkSubtitle, matchTitle, matchDesc, matchSubtitle, matchUniqueID, searchFor, caseSensitive, scheduleHelper, minLength, maxLength));
//Release resources held by the search engine object
search.Dispose();
//Verify the user has VLC installed by looking for it in the path that is set in the config
bool strmAllowed = File.Exists(Path.Combine(guideParams.strmVLCLoc, "vlc.exe"));
CSSProgrammeTableLoad tableLoad = new CSSProgrammeTableLoad();
foreach (Programme program in ProgrammeArray)
{
if (sr_searchResults.SelectedValue == "table")
{
displayProgrammeSort.Add(program);
}
else
{
ScheduledRecording scheduledRecording = null;
if (knownRecordings.Contains(program.getOID()))
scheduledRecording = (ScheduledRecording) knownRecordings[program.getOID()];
processTree(displayProgramme, program, scheduledRecording,
scheduleHelper.GetChannelByOID(program.getChannelOID()));
}
}
//Clear the arraylist of programmes to free up resources since we are done with it
ProgrammeArray.Clear();
if (sr_searchResults.SelectedValue == "tree")
{
//Resize the array of ProgrammeTreeItems so that is isn't hogging up space.
Array.Resize(ref pgmTree, treeIdx);
TreeView1.Nodes.Clear();
//Fill the TreView Control with all the nodes in the correct format
displayProgramme.FillProgrammeTree(TreeView1, pgmTree, srtOrder.SelectedValue);
}
else
{
//Sort the matching programmes into the choosen sort order
tableLoad.sortDisplay(sortOrders, displayProgrammeSort, false);
//Format the now sorted matching results into the CSS table format
while (displayProgrammeSort.Count > 0)
{
ScheduledRecording scheduledRecording = null;
Programme pgm = (Programme) displayProgrammeSort[0];
if (knownRecordings.Contains(pgm.getOID())) scheduledRecording = (ScheduledRecording)knownRecordings[pgm.getOID()];
tableLoad.processTable(pageType, sortOrders, Cache, Request, Server, displayProgramme, strmAllowed, pgm, scheduledRecording, false);
displayProgrammeSort.RemoveAt(0);
}
//Call the finalize process for creating the TableView
tableLoad.processTable(pageType, sortOrders, Cache, Request, Server, null, strmAllowed, null, null, true);
//Fill the aspx page with the formatted results
forcedScrollbar.InnerHtml = tableLoad.getForcedScrollBar();
CONTENTS.InnerHtml = tableLoad.getContents();
tableLoad.Dispose();
CONTENTS.Attributes.Add("onscroll", "fScroll(this)");
}
if (Recordings.Items.Count > 0)
{
DropDownList FailedRecordings = new DropDownList();
string [] programmeInfo;
knownRecordings = scheduleHelper.LoadKnownRecordings();
for (int i = 0; i < Recordings.Items.Count; i++)
{
programmeInfo = Recordings.Items[i].Value.Split('@');
if (!knownRecordings.Contains(System.Convert.ToInt32(programmeInfo[0])))
{
FailedRecordings.Items.Add(programmeInfo[1]);
}
}
if (FailedRecordings.Items.Count > 0)
{
Recordings.Items.Clear();
ListItem [] failures = new ListItem[FailedRecordings.Items.Count];
FailedRecordings.Items.CopyTo(failures,0);
Recordings.Items.AddRange(failures);
RecordMessage.Text = "Recordings That Failed to Schedule:";
ERROR_MESSAGE.Visible = true;
Recordings.Visible = true;
RecordMessage.Visible = true;
}
else
{
Recordings.Items.Clear();
ERROR_MESSAGE.Visible = false;
Recordings.Visible = false;
RecordMessage.Visible = false;
}
}
displayProgramme.Dispose();
}
#region Page Load code for the TreeView - ProcessTree
//This is the main driver routine for loading the TableView
private void processTree(ProgrammeDisplay2 displayProgramme, Programme programme, ScheduledRecording scheduledRecording, Channel chnl)
{
//Create a ProgrammeTreeItem to be loaded with the correct display information for the program
ProgramTreeItem treeItem = new ProgramTreeItem();
displayProgramme.FillProgrammeTreeArrayItem(treeItem, Server, programme, scheduledRecording, true, chnl);
//Add the loaded ProgrammeTreeITem to the Array
pgmTree[treeIdx] = treeItem;
treeIdx = treeIdx + 1;
}
#endregion
private void createHeaderRow() {
TableRow headerRow = new TableRow();
TableCell col1 = new TableCell();
col1.CssClass = "header";
col1.Text = "<nobr><input type=\"checkbox\" class=\"selectall\" onclick=\"SelectAllCheckboxes(this);\"><b>Select</b></nobr>";
headerRow.Cells.Add(col1);
TableCell col3 = new TableCell();
col3.CssClass = "header";
col3.Text = "Channel";
headerRow.Cells.Add(col3);
TableCell col3a = new TableCell();
col3a.CssClass = "header";
col3a.Text = "Show";
headerRow.Cells.Add(col3a);
TableCell col4 = new TableCell();
col4.CssClass = "header";
col4.Text = "Air Date";
headerRow.Cells.Add(col4);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.PreRender += new System.EventHandler(this.SearchResults_PreRender);
}
#endregion
}
}